package main

import "fmt"

//演示结构体channel
//和结构体指针channel
func main() {
	//结构体管道
	var stuChan chan Student
	stuChan = make(chan Student, 10)
	stuChan <- Student{ID: 1, Name: "呵呵"}
	stuChan <- Student{ID: 2, Name: "呵呵2"}

	stuResult := <-stuChan
	fmt.Printf("%v ", stuResult)

	//结构体指针管道
	var stuPointerChan chan *Student
	stuPointerChan = make(chan *Student, 20)
	stuPointerChan <- &Student{ID: 1, Name: "路飞"}
	stuTmp := <-stuPointerChan
	fmt.Printf("学生结构体指针:%v", stuTmp)

	//可以存放任意类型的管道
	allChan := make(chan interface{}, 20)
	allChan <- 10
	allChan <- "内容"
	allChan <- Student{ID: 2, Name: "乔巴"}
	allChan <- &Student{ID: 3, Name: "娜美"}

	fmt.Printf("%v", <-allChan)
	fmt.Printf("%v", <-allChan)
	fmt.Printf("%v", <-allChan)
	fmt.Printf("%v", <-allChan)

}

type Student struct {
	ID   int32
	Name string
}
